#include<stdio.h>
#include<stdlib.h>
struct student
{
    int num;
    char name[20];
    int score;
    struct student *next;
};
struct student* Create()
{
    struct student *head=NULL,*new_node=NULL,*tail = NULL;
    while(1)
    {
        new_node=(struct student*)malloc(sizeof(struct student));
        scanf("%d",&new_node->num);
        if(new_node->num==0)
        {
            free(new_node);break;
        }
        scanf("%s%d",new_node->name,&new_node->score);
        new_node->next=NULL;
        if(head==NULL)
        {
            head = new_node;
            tail = new_node;
        }
        else
        {
            tail->next=new_node;
            tail=new_node;
        }
    }
    return head;

}
void Delete(struct student **head, int target)
{
    for(struct student *p=*head,*q=NULL;p;q=p,p=p->next)
    {
        if(p->score<target)
        {
            if(q)
                q->next=p->next;
            else
                *head=p->next;   
            free(p);
            continue;
        }
    }
}
void Print(struct student* head)
{
    struct student *p;
    for(p=head;p;p=p->next)
    {
         printf("%d %s %d\n",p->num,p->name,p->score);
    }
}
int main()
{
    struct student *head;int target;
    head=Create();
    scanf("%d",&target);
    Delete(&head,target);
    Print(head);
}